Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-5511 fix: pagination #2906

Merged
merged 4 commits into from
Sep 16, 2024
Merged

CB-5511 fix: pagination #2906

merged 4 commits into from
Sep 16, 2024

Conversation

Wroud
Copy link
Member

@Wroud Wroud commented Sep 10, 2024

No description provided.

@Wroud Wroud self-assigned this Sep 10, 2024
@@ -240,6 +242,7 @@ export class UsersResource extends CachedMapResource<string, AdminUser, UserReso
}

const usersList: AdminUser[] = [];
const pages: Parameters<typeof this.offsetPagination.setPage>[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create a separate type for that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure that we need it, because we don't and can't use it anywhere to declare exact implementation, instead we have several places when we need to "delay" setPage call (we want to call it synchronously in same action with data mutation and after data mutation)

Probably we can want in future ability to delay setPage call via API but not with this array of arguments + for each + call

Comment on lines +25 to +26
from: true,
to: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why true?
may be observable also?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems strange

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's shorthand for from: observable

Comment on lines 358 to 363
// if (pageKey) {
// metadata.offsetPage = observable({
// ...metadata.offsetPage,
// pages: expandOffsetPageRange(metadata.offsetPage?.pages || [], pageKey.options, false),
// });
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this logic? should it be deleted at all or handled in a different way according to new api?
now I can see that pages wont be marked as loaded. is it correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will delete it, pages have different logic

@@ -114,39 +114,48 @@ export function limitOffsetPages(pages: IResourceOffsetPage[], limit: number): I
return result;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really hard to read what is going on here. please at least TODO to make it more readable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, removed (it's not in use anymore)

setPageEnd(key: ResourceAlias<TKey, Readonly<ICachedResourceOffsetPageOptions>>, hasNextPage: boolean): void {
const count = key.options.offset + key.options.limit;
setPage(key: ResourceAlias<TKey, Readonly<ICachedResourceOffsetPageOptions>>, items: any[], hasNextPage: boolean) {
items = [...items];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed

Comment on lines +25 to +26
from: true,
to: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems strange

from: true,
to: true,
items: observable.shallow,
outdated: observable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observable.ref maybe? as its a boolean

Copy link
Member Author

@Wroud Wroud Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no difference for primitives actually observable and observable.ref will have same effect (and true)

@Wroud Wroud merged commit 9e657d2 into devel Sep 16, 2024
7 checks passed
@Wroud Wroud deleted the fix/cb-5511/pagination branch September 16, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants